const {Sequelize} = require('sequelize')
const {database} = require('../config')

const sequelize = new Sequelize(database.dbName, database.user, database.password, {
  dialect: 'mysql',   // 指定数据库类型，必须安装mysql驱动——mysql2
  host: database.host,
  port: database.port,
  logging: false,     // 是否在终端显示sql语句
  timezone: '+08:00',
  define: {
    timestamps: false,     // 是否默认生成 createAt 和 updateAt 这两个字段
  }
})

sequelize.sync({
  force: false    // 一旦设置为true，就准备跑路吧
})

module.exports = sequelize